package org.liuyunfeng.wang;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author: TanJingyu
 * @create: 2023-02-17 16:18
 **/
public class MainTest {
    public static void main(String[] args) throws IOException {


        int a = 10;
        int b = 20;




        a = a ^ b;  // a = 10 ^ 20
        b = a ^ b;  // b = 10
        a = a ^ b;  // a = 20

        byte[] bytes = "你好".getBytes(StandardCharsets.UTF_8);
        InputStream inputStream = new ByteArrayInputStream(bytes);
        ArrayList<Integer> objects = new ArrayList<>();
        int num = 0;
        while (num != -1) {
            num = inputStream.read();
            if (num != -1) objects.add(num);
        }

        System.out.println(objects);
        byte[] bytes1 = new byte[objects.size()];
        for (int i = 0; i < bytes1.length; i++) {
            bytes1[i] = objects.get(i).byteValue();
        }

        System.out.println(new String(bytes1));

    }
}

    